package com.qianfeng.smsplatform.api.controller;/***
 *                    .::::.
 *                  .::::::::.
 *                 :::::::::::  
 *             ..:::::::::::'   木马~
 *           '::::::::::::'       
 *             .::::::::::       
 *        '::::::::::::::..
 *             ..::::::::::::.
 *           ``::::::::::::::::
 *            ::::``:::::::::'        .:::.
 *           ::::'   ':::::'       .::::::::.
 *         .::::'      ::::     .:::::::'::::.
 *        .:::'       :::::  .:::::::::' ':::::.
 *       .::'        :::::.:::::::::'      ':::::.
 *      .::'         ::::::::::::::'         ``::::.
 *  ...:::           ::::::::::::'              ``::.
 * ```` ':.          ':::::::::'                  ::::..
 *                    '.:::::'                    ':'````..
 */

import com.qianfeng.smsplatform.api.dto.R;
import com.qianfeng.smsplatform.api.exceptions.MyBaseException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author ：zl
 * @date ：Created in 2021/7/17 19:25
 */
@ControllerAdvice
@ResponseBody
public class MyControllerAdvice {

    /**
     * 处理自己定义的异常
     * @param exception
     * @return
     */
    @ExceptionHandler(MyBaseException.class)
    public R processMyBaseException(MyBaseException exception) {
        return R.getR(exception.getCode(), exception.getMessage(), null);
    }

}